﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using DLM.Infrastructure.Domain;

namespace DLM.Domain.Model
{
    public class Salutation : IValidatableObject, IAggregateRoot
    {
        public int SID { get; set; }

        [Required(ErrorMessage="请选择正确的招呼类型")]
        public int Type { get; set; }

        [Required(ErrorMessage="请选择正确的用户")]
        public int UserID { get; set; }

        public int GreetID { get; set; }
        
        [StringLength(15,ErrorMessage="消息最多允许15个字")]
        public string Message { get; set; }

        public bool IsConfirm { get; set; }
        public System.DateTime SentDate { get; set; }

        public virtual User User { get; set; }


        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (Type < 0)
            {
                yield return new ValidationResult("招呼类型不正确", new string[] { "Type" });
            }
        }
    }

    public enum GreetType
    {
        Normal = 0,
        Friend = 1,
        Phone=2
    }
}
